<!DOCTYPE html>

<html class="no-js">

<head>
  <meta charset="utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <title></title>
  <meta name="description" content="" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <script src="https://cdn.staticfile.org/axios/0.19.0-beta.1/axios.js"></script>
  <script src="https://cdn.staticfile.org/vue/2.5.17/vue.js"></script>
  <link rel="stylesheet" href="https://cdn.staticfile.org/element-ui/2.13.0/theme-chalk/index.css" />
  <script src="https://cdn.staticfile.org/element-ui/2.13.0/index.js"></script>

  <link rel="stylesheet" href="../../../lib/index.css" />
  <script src="../../../lib/bee.js"></script>
</head>

<body>
  <div id="app">
    <bee-form :option="option" v-model="form"></bee-form>
  </div>
</body>
<script>
    var baseUrl = 'https://cli.avuejs.com/api/area'
    new Vue({
    el: '#app',
      data(){
        return {
           form:{
              province: '110000',
              city: '110100',
              area: '110101',
              text1:'text1',
              text2: 'text2',
              text3: 'text23',
              dynamic: [
                  {
              province: '110000',
              city: '110100',
              area: '110101'}
              ]
           },
           option:{
            detail: true,
          labelPosition: 'left',
          labelWidth: 120,
              column: [{
                label: '省份',
                prop: 'province',
                type: 'select',
                detail: false,
                props: {
                  label: 'name',
                  value: 'code'
                },
                cascaderItem: ['city', 'area'],
                dicUrl: `${baseUrl}/getProvince`,
                dicFormatter:(res)=>{
                  return res.data;//返回字典的层级结构
                },
                rules: [
                  {
                    required: true,
                    message: '请选择省份',
                    trigger: 'blur'
                  }
                ]
              },{
                label:'文本框1',
                detail: true,
                prop:'text1'
              },
              {
                label: '城市',
                prop: 'city',
                type: 'select',
                detail: true,
                props: {
                  label: 'name',
                  value: 'code'
                },
                row: true,
                cascaderIndex:0,
                dicUrl: `${baseUrl}/getCity/{{key}}?province={{province}}`,
                // dicQuery:{
                //   city:'{{key}}',
                //   province:'{{province}}'
                // },
                rules: [
                  {
                    required: true,
                    message: '请选择城市',
                    trigger: 'blur'
                  }
                ]
              },{
                label:'文本框2',
                detail: true,
                prop:'text2'
              },{
                label:'文本框3',
                detail: true,
                prop:'text3'
              },
              {
                label: '地区',
                prop: 'area',
                type: 'select',
                detail: true,
                props: {
                  label: 'name',
                  value: 'code'
                },
                cascaderIndex:0,
                dicUrl: `${baseUrl}/getArea/{{key}}?city={{city}}`,
                rules: [
                  {
                    required: true,
                    message: '请选择地区',
                    trigger: 'blur'
                  }
                ]
              },{
            label: '子表单',
            prop: 'dynamic',
            type: 'dynamic',
            detail: true,
            span:24,
            children: {
            // type: 'form',
              align: 'center',
              headerAlign: 'center',
              rowAdd:(done)=>{
                this.$message.success('新增回调');
                  done({
                    input:'默认值'
                  });
              },
              rowDel:(row,done)=>{
                this.$message.success('删除回调'+JSON.stringify(row));
                done();
              },
              column: [{
                label: '省份',
                prop: 'province',
                type: 'select',
                props: {
                  label: 'name',
                  value: 'code'
                },
                cascaderItem: ['city', 'area'],
                dicUrl: `${baseUrl}/getProvince`,
                dicFormatter:(res)=>{
                  return res.data;//返回字典的层级结构
                },
                rules: [
                  {
                    required: true,
                    message: '请选择省份',
                    trigger: 'blur'
                  }
                ]
              },{
                label: '城市',
                prop: 'city',
                type: 'select',
                props: {
                  label: 'name',
                  value: 'code'
                },
                row: true,
                cascaderIndex:0,
                dicUrl: `${baseUrl}/getCity/{{key}}?province={{province}}`,
                // dicQuery:{
                //   city:'{{key}}',
                //   province:'{{province}}'
                // },
                rules: [
                  {
                    required: true,
                    message: '请选择城市',
                    trigger: 'blur'
                  }
                ]
              }, {
                label: '地区',
                prop: 'area',
                type: 'select',
                props: {
                  label: 'name',
                  value: 'code'
                },
                cascaderIndex:0,
                dicUrl: `${baseUrl}/getArea/{{key}}?city={{city}}`,
                rules: [
                  {
                    required: true,
                    message: '请选择地区',
                    trigger: 'blur'
                  }
                ]
              },{
                width: 200,
                label: '数字框',
                prop: "number",
                type: 'number'
              }]
            }
          },]
           }
        }
      }
  })
    </script>

</html>